home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / kolekce / d6 / rxlibsetup.exe / {app} / units / RxDBReg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-02-19  |  3.7 KB  |  128 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {                                                       }
  5. {         Copyright (c) 2001,2002 SGB Software          }
  6. {         Copyright (c) 1997, 1998 Fedor Koshevnikov,   }
  7. {                        Igor Pavluk and Serge Korolev  }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11.  
  12. unit RxDBReg;
  13.  
  14. {$I RX.INC}
  15. {$D-,L-,S-}
  16.  
  17. interface
  18.  
  19. uses Classes, RTLConsts, DesignIntf, DesignEditors, VCLEditors, SysUtils, DB;
  20.  
  21. { Register data aware custom controls and components }
  22.  
  23. procedure Register;
  24.  
  25. implementation
  26.  
  27. {$IFDEF WIN32}
  28.  {$R *.D32}
  29. {$ELSE}
  30.  {$R *.D16}
  31. {$ENDIF}
  32.  
  33. uses TypInfo, RXLConst, RXDBCtrl, RXLookup, RxLogin, RXDBComb, VCLUtils,
  34.   {$IFNDEF RX_D3} DBTables, {$ENDIF} {$IFDEF DCS} SelDSFrm, {$ENDIF} 
  35.   {$IFDEF RX_D3} RxMemDS, {$ENDIF} {$IFDEF WIN32} DBRichEd, {$ENDIF} 
  36.   Consts, LibHelp, RxDsgn;
  37.  
  38. { TRxFieldProperty }
  39. { For TRxDBLookupList, TRxDBLookupCombo components }
  40.  
  41. type
  42.   TRxFieldProperty = class(TRxDBStringProperty)
  43.   public
  44.     procedure GetValueList(List: TStrings); override;
  45.     function GetDataSourcePropName: string; virtual;
  46.   end;
  47.  
  48. function TRxFieldProperty.GetDataSourcePropName: string;
  49. begin
  50.   Result := 'LookupSource';
  51. end;
  52.  
  53. procedure TRxFieldProperty.GetValueList(List: TStrings);
  54. var
  55.   Instance: TComponent;
  56.   PropInfo: PPropInfo;
  57.   DataSource: TDataSource;
  58. begin
  59.   Instance := TComponent(GetComponent(0));
  60.   PropInfo := TypInfo.GetPropInfo(Instance.ClassInfo, GetDataSourcePropName);
  61.   if (PropInfo <> nil) and (PropInfo^.PropType^.Kind = tkClass) then
  62.   begin
  63.     DataSource := TObject(GetOrdProp(Instance, PropInfo)) as TDataSource;
  64.     if (DataSource <> nil) and (DataSource.DataSet <> nil) then
  65.       DataSource.DataSet.GetFieldNames(List);
  66.   end;
  67. end;
  68.  
  69. {$IFDEF DCS}
  70. {$IFDEF RX_D3}
  71.  
  72. { TMemoryDataEditor }
  73.  
  74. type
  75.   TMemoryDataEditor = class(TMemDataSetEditor)
  76.   protected
  77.     function CopyStructure(Source, Dest: TDataSet): Boolean; override;
  78.   end;
  79.  
  80. function TMemoryDataEditor.CopyStructure(Source, Dest: TDataSet): Boolean;
  81. begin
  82.   Result := Dest is TRxMemoryData;
  83.   if Result then
  84.     TRxMemoryData(Dest).CopyStructure(Source);
  85. end;
  86.  
  87. {$ENDIF RX_D3}
  88. {$ENDIF DCS}
  89.  
  90. { Designer registration }
  91.  
  92. procedure Register;
  93. begin
  94.  
  95. {$IFDEF RX_D4}
  96.   { Database Components are excluded from the STD SKU }
  97.   if GDAL = LongWord(-16) then Exit;
  98. {$ENDIF}
  99.  
  100. { Data aware components and controls }
  101.   RegisterComponents(LoadStr(srRXDBAware), [
  102.     {$IFDEF RX_D3} TRxMemoryData, {$ENDIF}
  103.     TRxDBGrid, TRxDBLookupList, TRxDBLookupCombo, TRxLookupEdit, TDBDateEdit, 
  104.     TRxDBCalcEdit, TRxDBComboEdit, {$IFDEF WIN32} TRxDBRichEdit, {$ENDIF}
  105.     TDBStatusLabel, TRxDBComboBox]);
  106.   RegisterComponents(LoadStr(srRXTools), [TRxLoginDialog]);
  107. {$IFDEF RX_D3}
  108.   RegisterNonActiveX([TRxMemoryData, TRxDBGrid, TDBDateEdit, 
  109.     TDBStatusLabel, TRxDBComboBox, TRxDBLookupList,
  110.     TRxDBLookupCombo, TRxLookupEdit, TRxDBComboEdit, TRxDBCalcEdit, 
  111.     TRxDBRichEdit, TCustomDBComboBox, TRxLookupControl, TRxLoginDialog], 
  112.     axrComponentOnly);
  113. {$ENDIF RX_D3}
  114. { Property and component editors for data aware components }
  115.   RegisterPropertyEditor(TypeInfo(string), TRxLookupControl, 'LookupField',
  116.     TRxFieldProperty);
  117.   RegisterPropertyEditor(TypeInfo(string), TRxLookupEdit, 'LookupField',
  118.     TRxFieldProperty);
  119. {$IFDEF RX_D3}
  120.   RegisterPropertyEditor(TypeInfo(Integer), TRxDBGrid, 'RowsHeight', nil);
  121. {$IFDEF DCS}
  122.   RegisterComponentEditor(TRxMemoryData, TMemoryDataEditor);
  123. {$ENDIF DCS}
  124. {$ENDIF RX_D3}
  125.  
  126. end;
  127.  
  128. end.